import Hex from './Hex'
import Text from './Text';
/**
 * 
 * @param {*} param0 
 * @param {ArrayBuffer} param0.buffer
 * @returns 
 */
export default function  ({buffer}) {
    const unitArr = new Uint8Array(buffer);
    const numberArr =[]; 
    unitArr.forEach(v => {
    //   let str = v.toString(16);
    //   str = str.length == 1? `0${str}`:str 
    numberArr.push(v)
    });
    // 每行16个 
    const numberArrWithRow = []
    numberArr.forEach((qaq,index) => {
        const yu = index % 16
        const nowRow = (index -yu)/16
        if (yu === 0) {
            numberArrWithRow[nowRow] = []
        }
        numberArrWithRow[nowRow][yu]=qaq;
    })
    return(<div className="flex w-full  gap-2">
        <Hex data={numberArrWithRow} />
        <Text data={numberArrWithRow} />
    </div>)
}